class AdminController {

    def show = {
        def a = session.access
        a.refresh()
        if(a.hasDevAuth()){
           redirect(uri:"/");
        }
        render(view:'show')
    }

    def lock={

        def containerInstance = Container.get( params.containerId )
        containerInstance.budgetLocked = !containerInstance.budgetLocked
        if(!containerInstance.hasErrors() && containerInstance.save(flush:true,validate:false)) {
            flash.message="budget locked"
            render(view:'show')
        }
        else{
            flash.message="error!"
            containerInstance.errors.each {
                      println(it);
                    }
            render(view:'show')
        }
    }

    def unlock={
        def containerInstance = Container.get( params.containerId )
        containerInstance.budgetLocked = !containerInstance.budgetLocked
        if(!containerInstance.hasErrors() && containerInstance.save(flush:true,validate:false)) {
            flash.message="budget unlocked"
            render(view:'show')
        }
        else{
            flash.message="error!"
            containerInstance.errors.each {
                      println(it);
                    }
            render(view:'show')
        }
    }
}
